import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class demo01 {
    //两种排序方法
    public static void main(String[] args) throws IOException {
//        Scanner sc=new Scanner(System.in);
//        int n=sc.nextInt();
//        sc.nextLine();
//        String[] arr=new String[n];
//        for (int i = 0; i < n; i++) {
//            arr[i]=sc.nextLine();
//        }
        BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(r.readLine());
        String[] arr=new String[n];
        for (int i = 0; i < n; i++) {
            arr[i]=r.readLine();
        }
        int flag1=func1(arr);
        int flag2=func2(arr);
        if(flag1==1&&flag2==1){
            System.out.println("both");
        } else if (flag1==1) {
            System.out.println("lexicographically");
        } else if (flag2==1) {
            System.out.println("lengths");
        }else {
            System.out.println("none");
        }
    }
    public static int func1(String[] arr){
        for (int i = 0; i < arr.length-1; i++) {
            if(arr[i].compareTo(arr[i+1])>0){
                return 0;
            }
        }
        return 1;
    }
    public static int func2(String[] arr){
        for (int i = 0; i < arr.length-1; i++) {
            if(arr[i].length()>arr[i+1].length()){
                return 0;
            }
        }
        return 1;
    }
}
